import de.bezier.data.sql.*;

final int nSkills = 3;
final int nAttributes = 7;
final int nCombatSkills = 6;
final int nElements = 5;

final int sword = 0;
final int axe = 1;
final int distance = 2;
final int shielding = 3;
final int fist = 4;
final int club = 5;

final int head = 0;
final int armor = 1;
final int weapon = 2;
final int shield = 3;
final int legs = 4;
final int foot = 5;

final int aFor = 0;
final int aInt = 1;
final int aDex = 2;
final int aCar = 3;
final int aSor = 4;
final int aVit = 5;
final int aAgi = 6;

final int cNenhuma = 0;
final int cMago = 1;
final int cDruida = 2;
final int cPaladino = 3;
final int cGuerreiro = 4;

final int sCooking = 0;
final int sFishing = 1;
final int sCrafting = 2;

void ataque(Personagem A, Personagem D){
  int cS = A.getSkill();
  int w = A.getWAtk();
  float critico = (cS/w >= 0.6) ? 0.25 : (0.42*cS/w);
  int dexRagiD = floor(0.1*D.getAttribute(aDex) + 0.9*D.getAttribute(aAgi));
  int dexRagiA = floor(0.9*A.getAttribute(aDex) + 0.1*A.getAttribute(aAgi));
  int pesoRcapD = floor(D.getPWeight);
  int pesoRcapA = floor(A.getPWeight);
  int def = pesoRCapD < 0.5 ? dexRagiD : dexRagiD*(1-pesoRcapD);
  int atk = pesoRCapA < 0.5 ? dexRagiA : dexRagiA*(1-pesoRcapA);
  float sTax = A/(A+D);
  float pCritico = sTax*critico;
  float r = random(1, 100);
  int d = D.calcDef() - A.calcDamage();
  d = d > 0 ? 0 : d;
  if (r >= pCritico*100) D.addHp(d*1.2);
  else if (r > sTax*100) D.addHp(d);
}

void setup(){
//TESTES!
  Weapon Super_Espada = new Weapon(10, 5, sword, 10, true);
  Shield Super_Escudo = new Shield(30, 15);
  Shield Super_Escudo2 = new Shield(30, 15);  
  Personagem P1 = new Personagem("Cacildo");
  Personagem P2 = new Personagem("AtresmoXD");
  P1.addAttribute(aFor);
  P1.addCSkill(sword);
  P1.toEquip(Super_Espada);
  P2.toEquip(Super_Espada);
  P2.toUnEquip(Super_Espada);
  P2.toEquip(Super_Escudo);
  P2.toEquip(Super_Escudo2);
  P2.addHpMax(10);
  P2.addHp(100);
  ataque(P1, P2);
  P2.getStatus();
}
